package basicQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/v3/basicQuizzes/students/1/assignments/1/quizzes/1")
                , consumer(regex("/api/v3/basicQuizzes/students/\\d+/assignments/\\d+/quizzes/[\\s\\S]+"))))
    }
    response {
        status(200)
        body("""
            [
                {
                    "id":123,
                    "description":"description",
                    "type":"SINGLE_CHOICE",
                    "answer":"A",
                    "quizGroupId":1,
                    "createTime":"2018-08-08 00:00:00",
                    "updateTime":"2018-08-08 00:00:00",
                    "makerId":1,
                    "choices":[
                    ],
                    "tags":[
                    ],
                    "available":"true",
                    "userAnswer":"",
                    "isCorrect":""
                }
            ]
            """)
        bodyMatchers {
            jsonPath('$.[*]', byType())
            jsonPath('$.[*].id', byRegex(number()))
            jsonPath('$.[*].description', byType())
            jsonPath('$.[*].type', byType())
            jsonPath('$.[*].answer', byType())
            jsonPath('$.[*].quizGroupId', byRegex(number()))
            jsonPath('$.[*].createTime', byType())
            jsonPath('$.[*].updateTime', byType())
            jsonPath('$.[*].makerId', byRegex(number()))
            jsonPath('$.[*].choices', byType())
            jsonPath('$.[*].tags', byType())
            jsonPath('$.[*].available', byType())
            jsonPath('$.[*].userAnswer', byType())
            jsonPath('$.[*].isCorrect', byType())
        }
        headers {
            contentType(applicationJson())
        }
    }
}
